package com.xframe.xdal.core.listener.model;



import com.xframe.xdal.core.manage.DBTableInfo;
import com.xframe.xdal.core.util.StringUtil;
import lombok.Data;

import java.util.Date;
import java.util.Map;

/**
 * 数据行变化事件对象
 *
 * @author xufeng
 */
@Data
public class RowChangedEvent {


    /**
     * 流程处理ID
     */
    private Long processID;
    /**
     * 事件名称 UPDATE INSERT DELETE
     */
    private String event;
    /**
     * 数据  ORACLE 数据 当DELETE 时 只有ROEID
     */
    private Map<String, Object> dataMap;
    /**
     * 更的数据表结构
     */
    private DBTableInfo sourceTableInfo;
    /**
     * 数据库名称
     */
    private String dbName;
    /**
     * 数据库类型
     */
    private String dbType;


    /**
     * 时间戳
     */
    private Long time;

    public RowChangedEvent(){

    }


    public RowChangedEvent(String dbName,String dbType,DBTableInfo sourceTableInfo,
                           String event, Map<String, Object> data,Long processID) {
        this.sourceTableInfo = sourceTableInfo;
        this.dbName = dbName;
        this.dbType = dbType;
        this.event = event;
        this.dataMap = data;
        this.processID = processID;
        this.time = new Date().getTime();
    }






    @Override
    public String toString() {
        return StringUtil.objToJson(this);
    }
}
